import { RouteObject, useRoutes } from 'react-router-dom';
import BaseLayout from "./layout/baseLayout";
import Test from "./pages/test";
import Books from "./pages/books";
import User from "./pages/user";
import NotFundPage from './pages/404.tsx';
import SubAdmin from "./pages/subAdmin";


import Login from "./pages/login";

const routes: RouteObject[] = [
    {
        path: '/',
        element: (<BaseLayout/>),
        children:[
            {
                path: '/subAdmin',
                element: (<SubAdmin />),
            },
            {
                path: '/books',
                element: (<Books />),
            },
            {
                path: '/user',
                element: (<User />),
            },
            {
                path: '/borrow',
                children:[
                    {
                        path: '/borrow/borrowRecords',
                        element: (<div>图书借阅</div>),
                    },
                    {
                        path: '/borrow/returnRecord',
                        element: (<div>图书归还</div>),
                    },
                ]
            }
        ]
    },
    {
        path: '/login',
        element: (<Login />),
    },
    {
        path: '*',
        element: <NotFundPage/>,
    },
];

export default function Router() {
    const element = useRoutes(routes);
    return element;
}
